package com.xmh.util;

import com.xmh.ssm.utils.FileUtil;
import org.junit.Test;

import java.io.File;

public class ReadBookUtil {

    @Test
    public void readBookTest() throws InterruptedException {
        int charLength = 110;

        long stopTime = 5500L;

        String bookPath = this.getClass().getResource("/other/yuanlong.txt").getPath();

        String bookMarkPath = this.getClass().getResource("/other/bookMarkpath.txt").getPath();

        String fileStr = FileUtil.getFileStr(bookPath);

        String replace = fileStr.replace(fileStr.substring(0, fileStr.indexOf(FileUtil.getFileStr(bookMarkPath))), "");

        String[] split = replace.split("\r\n\r\n");

        for (String s : split) {
            StringBuilder stringBuilder = new StringBuilder(s);
            if (s.length() > charLength) {
                stringBuilder.insert(charLength, "\n");
            }
            if (s.length() > charLength * 2) {
                stringBuilder.insert(charLength * 2, "\n");
            }
            System.out.println(stringBuilder.append("\n"));

//            FileUtil.outFile(s, bookMarkPath);
//            Thread.sleep(stopTime);
        }
    }

}
